/*
 *
 *过滤器
 */

import dayjs from 'dayjs';
import accounting from 'accounting';

export default {
  phoneFilter: function(val) {
    return val.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
  },
  strTonum: function(val) {
    return parseInt(val);
  },
  toFixed: function(val) {
    return accounting.toFixed(val, 2);
  },
  formatDate: function (value, formatString) {
    if (!value) return;
    formatString = formatString || 'YYYY-MM-DD HH:mm:ss';
    return dayjs(parseInt(value)).format(formatString);
  }
};
